package com.designpattern.StrategyPattern.example1;

/**
 * @Author yp
 * @Date 2021-05-24
 * @Description 策略类
 **/

public interface Strategy {

    int doOperation(int num1, int num2);
}


/**
 * @Author yp
 * @Date 2021-05-24
 * @Description 加法运算
 **/

class OperationAdd implements Strategy {
    @Override
    public int doOperation(int num1, int num2) {
        System.out.println("add: " + num1 + "+" + num2);
        return num1 + num2;
    }
}


/**
 * @Author yp
 * @Date 2021-05-24
 * @Description 除法运算
 **/

class OperationDivide implements Strategy {
    @Override
    public int doOperation(int num1, int num2) {
        System.out.println("divide: " + num1 + "/" + num2);
        return num1 / num2;
    }
}

/**
 * @Author yp
 * @Date 2021-05-24
 * @Description 运算乘积
 **/

class OperationMultiply implements Strategy {
    @Override
    public int doOperation(int num1, int num2) {
        System.out.println("multiply: " + num1 + "*" + num2);
        return num1 * num2;
    }
}


/**
 * @Author yp
 * @Date 2021-05-24
 * @Description 减法运算
 **/

class OperationSubtract implements Strategy {
    @Override
    public int doOperation(int num1, int num2) {
        System.out.println("substract: " + num1 + "-" + num2);
        return num1 - num2;
    }
}


